#pragma once
#include <string>
#include <vector>
#include <windows.h>

class CTap
{
public:
	CTap();
	~CTap();
	bool open();
	void get_mac(void* buf);
	const std::string& name();
	bool start_with_address(DWORD ip, DWORD mask);
	bool start_with_address(const char* ip, const char* mask);
	void netsh_set_address(const char* ip, const char* mask);
	void netsh_set_address(DWORD ip, DWORD mask);
	DWORD get_address();
	
	// read a packet being sent
	size_t read(void* buf, size_t size);

	// write a packet being recvd
	size_t write(void* buf, size_t size);

	void close();

	static void test();

private:
	std::vector<std::string> _guids, _names;
	HANDLE _h, _read_event, _write_event;

	size_t _index;

	void read_reg_adapters();
	void read_reg_names();
};

